'''
https://leetcode.cn/problems/missing-number/description/
'''
from typing import List


class Solution:
    def missingNumber(self, nums: List[int]) -> int:
        xor_all = xor_has = 0
        for i, num in enumerate(nums):
            xor_has ^= num
            xor_all ^= i
        xor_all ^= len(nums)
        return xor_has ^xor_all
